package com.neusoft.demo10;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetDemo {
    public static void main(String[] args) {
        //创建一个Set集合
        Set<Employee> set = new HashSet<Employee>();
        Employee e1 = new Employee();
        e1.setName("fender");
        Employee e2 = new Employee();
        e2.setName("gibson");
        //向Set集合中添加一个元素
        set.add(e1);
        set.add(e2);
        //遍历Set集合
        Iterator<Employee> it = set.iterator();
        while(it.hasNext()){
            Employee employee = it.next();
            System.out.println(employee.getName());
        }
    }
}
